package com.toycloud.business.controller.baseConfig;

import com.toycloud.business.dto.params.*;
import com.toycloud.business.dto.results.CascaderLabelResult;
import com.toycloud.business.dto.results.CommonResult;
import com.toycloud.system.domain.dto.FeedbackLabelDTO;
import com.toycloud.system.domain.feedback.FeedbackConfig;
import com.toycloud.business.service.IFeedbackConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author hlchan
 * @version 1.0
 * @date 2024/9/4 17:37
 */
@RestController
@RequestMapping("/baseConfig")
public class BaseConfigController {

    @Autowired
    IFeedbackConfigService feedbackConfigService;

    /**
     * 获取基础配置信息数据
     */
    @GetMapping("/list")
    public CommonResult<List<FeedbackConfig>> list(@Valid  FeedbackConfigTypeParams params) {
        return feedbackConfigService.getBaseConfig(params);
    }

    /**
     * 获取(有效)基础配置信息数据
     */
    @GetMapping("/getUsedConfigList")
    public CommonResult<List<FeedbackConfig>> getUsedConfigList() {
        return feedbackConfigService.getUsedConfigList();
    }

    /**
     * 增加基础配置信息数据
     */
    @PostMapping("/add")
    public CommonResult add(@Valid @RequestBody FeedbackConfigParam param) {
        return feedbackConfigService.addBaseConfig(param);
    }

    /**
     * 修改基础配置信息数据
     */
    @PostMapping("/update")
    public CommonResult update(@Valid @RequestBody FeedbackConfigUpadateParam param) {
        return feedbackConfigService.updateBaseConfig(param);
    }

    /**
     * 删除基础配置信息数据
     */
    @PostMapping("/remove")
    public CommonResult remove(@Valid @RequestBody FeedbackConfigIdParam param) {
        return feedbackConfigService.removeBaseConfig(param);
    }




    @PostMapping("/getLabelList")
    public CommonResult<List<FeedbackLabelDTO>> list(@Valid @RequestBody FeedbackLabelParams params) {
        return feedbackConfigService.getFeedbackLabelList(params);
    }

    @PostMapping("/saveLabel")
    public CommonResult<Boolean> save(@Valid @RequestBody SaveFeedbackLabelParams param) {
        return feedbackConfigService.SaveFeedbackLabelParam(param);
    }

    @GetMapping("/deleteLabel")
    public CommonResult<Boolean> delete(long id,int pid) {
        return feedbackConfigService.deleteLabel(id,pid);
    }

    @GetMapping("/getCascaderLabel")
    public CommonResult<CascaderLabelResult> list() {
        return feedbackConfigService.getCascaderLabel();
    }

    @GetMapping("/getCascaderTypeLabel")
    public CommonResult<CascaderLabelResult> Typelist() {
        return feedbackConfigService.getCascaderTypeLabel();
    }

    @GetMapping("/getCascaderTree")
    public CommonResult<CascaderLabelResult> listTree(String[] types) {
        return feedbackConfigService.getCascader(types);
    }




}
